package com.hc.bytebit;

import java.io.UnsupportedEncodingException;

/**
 * @author : Henry
 * {@code CreateTime}: 2025-08-25 22:58
 * {@code Version}: 1.0
 */
public class ByteBit {
    public static void main(String[] args) throws UnsupportedEncodingException {
//        String a = "a";
        /**
         * UTF-8：一个中文对应3个字节
         * GBK：一个中文对应2个字节
         */
        String a = "尚";
        printByteBit(a);
    }

    private static void printByteBit(String a) throws UnsupportedEncodingException {
//        byte[] bytes = a.getBytes();
        byte[] bytes = a.getBytes("GBK");
        for (byte b : bytes) {
            int c = b;
            System.out.println(c);
            // byte 字节，对应的bit是多少
            String s = Integer.toBinaryString(c);
            System.out.println(s);
        }
    }
}
